import http from '@/http/index'

const API_URL = '/api/flexi-page/templates';

export const findAll = async (params: any) => {
  const response = await http({
    method: 'GET',
    path: API_URL,
    params,
  });
  return response.data;
};

export const findById = async (id: number) => {
  const response = await http({
    method: 'GET',
    path: `${API_URL}/${id}`,
    params: {},
  });
  return response.data;
};

export const create = async (templateData: any) => {
  const response = await http({
    method: 'POST',
    path: API_URL,
    params: templateData,
  });
  return response.data;
};

export const update = async (id: number, templateData: any) => {
  await http({
    method: 'PUT',
    path: `${API_URL}/${id}`,
    params: templateData,
  });
};

export const deleteById = async (id: number) => {
  await http({
    method: 'DELETE',
    path: `${API_URL}/${id}`,
    params: {},
  });
};